package com.hubei.car.utils;

/**
 * 计算经纬度距离
 * @author luokangtao
 * @create 2019-09-11 11:25
 */
public class LocationUtils {
    private static double EARTH_RADIUS = 6378.137;

    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }

    /**
     * 通过经纬度获取距离(单位：米)
     *
     * @param lat1
     * @param lng1
     * @param lat2
     * @param lng2
     * @return 距离
     */
    public static double getDistance(double lat1, double lng1, double lat2,
                                     double lng2) {
        double radLat1 = rad(lat1);
        double radLat2 = rad(lat2);
        double a = radLat1 - radLat2;
        double b = rad(lng1) - rad(lng2);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
                + Math.cos(radLat1) * Math.cos(radLat2)
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000d) / 10000d;
        s = s * 1000;
        return s;
    }

    public static void wx() throws Exception {
        String data = "6VJGmRYaW8kq8zFsbXk40tHCXBPE7ArT9/E17UjYszTSN3/DQeg1e5TGnD4OxH2oozgqxdT+97Z5/Y29cX3VVRTRWZ3VTl3MP5OB7Od60L7YfV36f9ywQDt9BF+Bx5RTqEjPWzzANYBzeEWfsha9vn3gNJDWlVrxYkBpQgu0gDcikQY3EwSYIE6ktynH+F4z0HJiLyX/e0i87mu71jkRtr6pDY5jiYsvXNGzlX4fllLk0nPuWafH4N6gsWUTHKmclKqucIJGuJsaHqp1HRGBwD8YC82EKb0MhzI79nbSmuvm1e3lZ/wKnlvDh5S/677H/Q2owZLUflpspWBgPF5WAuvfMGBQtXpr5GUSJl7wAV8hH+5SM7UM4Nf+kapU7wmSKQoL+BUv79siYT3enKVnbFZe7BM4HPdy7/uOSJmqr429EaSFBUzXKTEUBmtV9KUIGP3xcG574SFsQmwKLyK7PVu6sVtXYWi/U8H9Cy2InlCdqOVnN7rEFRKNTdoDWK7L";
        String sessionKey = "WkQcO9hNcNLL2riUrxLADw==";
        String iv = "uS40MblUrL/Q549Az2Sbig==";

        String decrypts = AesCbcUtil.decrypt(data, sessionKey, iv, "utf-8");
        System.out.println("========================");
        System.out.println(decrypts);
        System.out.println("========================");
    }

    public static void main(String[] args) {
        String tt = "ttt,bbb,cc";
        String[] iamge = tt.split(",");
        System.out.println(iamge[0]);
    }

}
